package thread;

/**
 * 获取线程相关信息
 */
public class ThreadInfoDemo {
    public static void main(String[] args) {
        Thread main = Thread.currentThread();//获取主线程
        //id:唯一标识 唯一标识:该值可以唯一表示一个信息
        long id = main.getId();
        System.out.println("id:"+id);
        //或取线程名字
        String name = main.getName();
        System.out.println("name:"+name);
        //获取线程的优先级
        int priority = main.getPriority();
        System.out.println("priority:"+priority);
        //线程是否还活着
        boolean isAlive = main.isAlive();
        System.out.println("-:"+isAlive);
        //是否为守护线程
        boolean isDaemon = main.isDaemon();
        System.out.println("isDaemon:"+isDaemon);
        //线程是否被中断
        boolean isInterrupted = main.isInterrupted();
        System.out.println("isInterrupted:"+isInterrupted);

    }
}
